#ifndef PLAYERCONTROL_H
#define PLAYERCONTROL_H
#include <SFML/Window/Event.hpp>
#include <SFML/Window/Window.hpp>

class PlayerControl{
    public:
    PlayerControl(const sf::Window &win);

    enum Controls{
        CONTROL_UP=1,
        CONTROL_DOWN=2,
        CONTROL_LEFT=4,
        CONTROL_RIGHT=8,
        CONTROL_BUTTON1=16,
        CONTROL_BUTTON2=32
    };

    virtual void Update()=0;
    bool ControlPressed(Controls c);

    protected:
    int controlStatus; // guarda un bit para saber si cada control esta apretado o no
    const sf::Window &w;
};



class KeyboardControl: public PlayerControl{
    private:
    sf::Key::Code up, down, left, right, button1, button2;

    public:
    // constructor: recibe las constantes de teclas de SFML para las teclas en este orden:
    // arriba, abajo, izquierda, derecha, boton1, boton2
    // por defecto WASD y G,H como los botones
    KeyboardControl(const sf::Window &w, sf::Key::Code up=sf::Key::W, sf::Key::Code down=sf::Key::S, sf::Key::Code left=sf::Key::A, sf::Key::Code right=sf::Key::D, sf::Key::Code button1=sf::Key::G, sf::Key::Code button2=sf::Key::H);
    virtual void Update();
};


class JoystickControl: public PlayerControl{
    private:
    unsigned int joyId;

    public:
    JoystickControl(const sf::Window &w, unsigned int joyId=0);
    virtual void Update();
};


#endif // PLAYERCONTROL_H
